home *** CD-ROM | disk | FTP | other *** search
/ Internet Info 1994 March / Internet Info CD-ROM (Walnut Creek) (March 1994).iso / networking / ip / ka9q / aztecnos.arc / IP.H < prev    next >
Encoding:
C/C++ Source or Header  |  1989-03-13  |  4.5 KB  |  147 lines

  1. #ifndef    NROUTE
  2.  
  3. #include "global.h"
  4. #include "timer.h"
  5.  
  6. #define    NROUTE    5    /* Number of hash chains in routing table */
  7.  
  8. extern int32 Ip_addr;    /* Our IP address for ICMP and source routing */
  9.  
  10. extern char Ip_ttl;    /* Default time-to-live for IP datagrams */
  11.  
  12. #define    IPVERSION    4
  13. /* IP header, INTERNAL representation */
  14. struct ip {
  15.     char version;        /* IP version number */
  16.     char tos;        /* Type of service */
  17.     int16 length;        /* Total length */
  18.     int16 id;        /* Identification */
  19.     int16 offset;        /* Fragment offset in bytes */
  20.     struct {
  21.         char df;    /* Don't fragment flag */
  22.         char mf;    /* More Fragments flag */
  23.     } flags;
  24.  
  25.     char ttl;        /* Time to live */
  26.     char protocol;        /* Protocol */
  27.     int32 source;        /* Source address */
  28.     int32 dest;        /* Destination address */
  29.     char options[44];    /* Options field */
  30.     int16 optlen;        /* Length of options field, bytes */
  31. };
  32. #define    NULLIP    (struct ip *)0
  33. #define    IPLEN    20    /* Length of standard IP header */
  34.  
  35. /* Fields in option type byte */
  36. #define    OPT_COPIED    0x80    /* Copied-on-fragmentation flag */
  37. #define    OPT_CLASS    0x60    /* Option class */
  38. #define    OPT_NUMBER    0x1f    /* Option number */
  39.  
  40. /* IP option numbers */
  41. #define    IP_EOL        0    /* End of options list */
  42. #define    IP_NOOP        1    /* No Operation */
  43. #define    IP_SECURITY    2    /* Security parameters */
  44. #define    IP_LSROUTE    3    /* Loose Source Routing */
  45. #define    IP_TIMESTAMP    4    /* Internet Timestamp */
  46. #define    IP_RROUTE    7    /* Record Route */
  47. #define    IP_STREAMID    8    /* Stream ID */
  48. #define    IP_SSROUTE    9    /* Strict Source Routing */
  49.  
  50. /* Timestamp option flags */
  51. #define    TS_ONLY        0    /* Time stamps only */
  52. #define    TS_ADDRESS    1    /* Addresses + Time stamps */
  53. #define    TS_PRESPEC    3    /* Prespecified addresses only */
  54.  
  55. /* IP routing table entry */
  56. struct route {
  57.     struct route *prev;    /* Linked list pointers */
  58.     struct route *next;
  59.     int32 target;        /* Target IP address */
  60.     int32 gateway;        /* IP address of local gateway for this target */
  61.     struct iface *iface;    /* Device interface structure */
  62. };
  63. #define    NULLROUTE    (struct route *)0
  64. extern struct route *Routes[32][NROUTE];    /* Routing table */
  65. extern struct route R_default;            /* Default route entry */
  66.  
  67. /* Cache for the last-used routing entry, speeds up the common case where
  68.  * we handle a burst of packets to the same destination
  69.  */
  70. struct rt_cache {
  71.     int32 target;
  72.     struct route *route;
  73. };
  74. extern struct rt_cache Rt_cache;
  75.  
  76. /* Reassembly descriptor */
  77. struct reasm {
  78.     struct reasm *next;    /* Linked list pointers */
  79.     struct reasm *prev;
  80.     int32 source;        /* These four fields uniquely describe a datagram */
  81.     int32 dest;
  82.     int16 id;
  83.     char protocol;
  84.     int16 length;        /* Entire datagram length, if known */
  85.     struct timer timer;    /* Reassembly timeout timer */
  86.     struct frag *fraglist;    /* Head of data fragment chain */
  87. };
  88. #define    NULLREASM    (struct reasm *)0
  89.  
  90. /* Fragment descriptor in a reassembly list */
  91. struct frag {
  92.     struct frag *prev;    /* Previous fragment on list */
  93.     struct frag *next;    /* Next fragment */
  94.     struct mbuf *buf;    /* Actual fragment data */
  95.     int16 offset;        /* Starting offset of fragment */
  96.     int16 last;        /* Ending offset of fragment */
  97. };
  98. #define    NULLFRAG    (struct frag *)0
  99.  
  100. extern struct reasm *Reasmq;    /* The list of reassembly descriptors */
  101.  
  102. /* IP error logging counters */
  103. struct ip_stats {
  104.     long total;        /* Total packets received */
  105.     unsigned runt;        /* Smaller than minimum size */
  106.     unsigned length;    /* IP header length field too small */
  107.     unsigned version;    /* Wrong IP version */
  108.     unsigned checksum;    /* IP header checksum errors */
  109.     unsigned badproto;    /* Unsupported protocol */
  110. };
  111. /* Structure for handling raw IP user sockets */
  112. struct raw_ip {
  113.     struct raw_ip *prev;
  114.     struct raw_ip *next;
  115.  
  116.     char protocol;        /* Protocol */
  117.     struct mbuf *rcvq;    /* receive queue */
  118. };
  119. #define    NULLRIP    ((struct raw_ip *)0)
  120.  
  121. extern struct ip_stats Ip_stats;
  122.  
  123. #if    defined(__STDC__) || defined(__TURBOC__)
  124. void del_ip(struct raw_ip *rrp);
  125. struct mbuf *htonip(struct ip *ip,struct mbuf *data);
  126. int ntohip(struct ip *ip,struct mbuf **bpp);
  127. int ip_route(struct mbuf *bp,int rxbroadcast);
  128. int rt_add(int32 target,unsigned int bits,int32 gateway,struct iface *iface);
  129. int rt_drop(int32 target,unsigned int bits);
  130. int16 ip_mtu(int32 addr);
  131. int16 cksum(struct pseudo_header *ph,struct mbuf *m,int16 len);
  132. #else
  133. void del_ip();
  134. struct mbuf *htonip();
  135. int ip_route();
  136. int rt_add();
  137. int rt_drop();
  138. int16 ip_mtu();
  139. int16 cksum();
  140. #endif
  141. struct raw_ip *raw_ip();
  142. void ip_recv(),tcp_input(),udp_input(),icmp_input();
  143.  
  144. #endif /* NROUTE */
  145.  
  146.  
  147.